package general.guicontrols.clusterpanels;

import general.art.Node;
import general.art.WeightedCenteredCluster;
import general.guicontrols.layoutmanager.CircularLayout;
import java.util.Map;
import java.util.HashMap;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import javax.swing.JPanel;

public class MouseOverDisplay extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	//private WeightedCenteredCluster cluster;

	private final Map<Node, NodePanel> nodeToNodePanel;
	private final Map<Node, MouseOverDisplay> nodeToCircularDisplay;
	private final CircularLayout cl;
	
	public MouseOverDisplay(WeightedCenteredCluster c){

		
		nodeToNodePanel = new HashMap<Node, NodePanel>();
		nodeToCircularDisplay = new HashMap<Node, MouseOverDisplay>();
		cl = new CircularLayout(c, nodeToNodePanel, nodeToCircularDisplay);
		//cluster = c;
		createContentFromCLuster(c);
		
		
	}

	private void createContentFromCLuster(WeightedCenteredCluster c){

		//Map<Component, Node>  cToN = new HashMap<Component, Node>();

		//nodeToNodePanel = new HashMap<Node, NodePanel>();

		for(Node n : c.getNodes()){

			if (n != c.getSeedNode()){
				NodePanel jb = CreateNodePanel(n);
				//cToN.put(jb, n);
				nodeToNodePanel.put(n, jb);
				this.add(jb);

			} 
		}
		
		this.setLayout( cl );


	}


	/**
	 * 
	 * 
	 */
	private NodePanel CreateNodePanel(final Node n){


		MouseAdapter d = new MouseAdapter(){};
		NodePanel tempB  = new NodePanel(n, d);
		tempB.setPreferredSize( new Dimension(100, 100));
		return tempB;


	}


}
